package com.exam.user.service;

import com.exam.user.api.entity.SysRole;
import com.exam.user.dao.SysRoleDao;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class SysRoleServiceImpl implements SysRoleService {

    @Resource
    private SysRoleDao sysRoleDao;

    @Override
    public void addRole(SysRole role) {
        sysRoleDao.addRole(role);
    }

    @Override
    public void deleteById(Integer id) {
        sysRoleDao.deleteById(id);
    }

    @Override
    public SysRole getSingle(Integer id) {

        return sysRoleDao.getSingle(id);
    }

    @Override
    public void updateById(SysRole role) {

        sysRoleDao.updateById(role);
    }

    @Override
    public PageInfo<SysRole> getAll(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        PageInfo<SysRole> roles=new PageInfo<>(sysRoleDao.getAll());
        return roles;
    }

    @Override
    public List<SysRole> getByLike(String roleName) {

        return sysRoleDao.getByLike(roleName);
    }
}
